﻿using System;
using System.Collections.Generic;
using System.Windows.Input;
using OpenLS.Drawing.UI.Internals;

namespace OpenLS.Drawing.UI.Internals
{
    class ShapeFillFormatter : ShapeFillFormatterBase
    {
       
        public ShapeFillFormatter(IShape model): base(model)
        {
        }

        protected override void SetFill (LineFillProperties fill)
        {
            EnsureShapeProperties().FillProperties = fill;
        }

        public override ColorBase SelectedColor
        {
            get
            {
                if (Model.ShapeProperties == null)
                    return null;
                if (Model.ShapeProperties.FillProperties == null)
                    return null;
                SolidColorFillProperties p = Model.ShapeProperties.FillProperties as SolidColorFillProperties;
                if (p == null)
                    return null;
                return p.Color;
            }
            set
            {
                if (value == null)
                    EnsureShapeProperties().FillProperties = null;
                else
                    EnsureShapeProperties().FillProperties = new SolidColorFillProperties(value);
            }
        }
        public FillProperties FillProperties { get { return EnsureShapeProperties().FillProperties; } }

        protected override Type GetFillType()
        {
            if (Model.ShapeProperties == null)
                return null;
            if (Model.ShapeProperties.FillProperties == null)
                return null;
            return Model.ShapeProperties.FillProperties.GetType();
        }
        public ShapeProperties ShapeProperties { get { return EnsureShapeProperties(); } }
    }
}